package app;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 用于封装application.properties的属性文件类
 *
 * @author chen.nie
 * @ Value("${key}") 读取值
 * @date 2018/6/24
 **/
@Component
public class PropertiesConfig {

    @Value("${spring.datasource.driver-class}")
    private String driverClass;
    @Value("${spring.datasource.url}")
    private String url;
    @Value("${spring.datasource.user}")
    private String userName;
    @Value("${spring.datasource.password}")
    private String password;

    @Value("${mybatis.typealias.packages}")
    private String mybatisTypeAliasPackages;
    @Value("${mybatis.mappers.location}")
    private String mapperLocations;
    @Value("${spring.mvc.view.suffix}")
    private String springWebMvcViewSuffix;
    @Value("${spring.mvc.view.prefix}")
    private String springWebMvcViewPrefix;

    @Value("${spring.mvc.static.resourceHandler}")
    private String springMvcStaticResourceHandler = "/static/**";

    @Value("${spring.mvc.static.resourceLocation}")
    private String springMvcStaticResourceLocation = "classpath:/static/";


    public String getSpringMvcStaticResourceHandler() {
        return springMvcStaticResourceHandler;
    }

    public String getSpringMvcStaticResourceLocation() {
        return springMvcStaticResourceLocation;
    }

    public int getSpringMvcStaticResourceCachePeriod() {
        return springMvcStaticResourceCachePeriod;
    }

    @Value("${spring.mvc.static.resource.cachePeriod}")
    private int springMvcStaticResourceCachePeriod = 30;

    public String getSpringWebMvcViewSuffix() {
        return springWebMvcViewSuffix;
    }

    public String getSpringWebMvcViewPrefix() {
        return springWebMvcViewPrefix;
    }

    public String getMapperLocations() {
        return mapperLocations;
    }

    public String getMybatisTypeAliasPackages() {
        return mybatisTypeAliasPackages;
    }

    public String getUrl() {
        return url;
    }

    public String getUserName() {
        return userName;
    }

    public String getPassword() {
        return password;
    }

    public String getDriverClass() {
        return driverClass;
    }
}
